/**
* AutoSWF - Cody Cushing. March 26, 2009
* Copyright (c) 2009 Cody Cushing
* No use restrictions. Maintain this notice in all versions. 
**/

package com.autoswf
{
	import com.autoswf.core.ILink;
	import com.autoswf.core.Transport;
	
	/**
	 * Convenience methods for connecting link nodes or retrieving a link node reference.
	 */
	public class LinkUtil
	{
		public static function join(parent:ILink, child:ILink):void
		{
			parent.addChildLink(child);
			child.addParentLink(parent);
		}
		
		public static function sever(parent:ILink, child:ILink):void
		{
			parent.removeChildLink(child);
			child.removeParentLink(parent);
		}
		
		/**
		 * 
		 * @param path  The id path to the link.
		 * @param link  The starting point of the path chain.
		 * @return A reference to the described link, or null if it is not found.
		 */
		public static function getLink(path:String, link:ILink):ILink
		{
			return link.sendDown(new Transport().setPath(path)) as ILink;
		}
	}
}